<?php
include "config/koneksi.php";
if($_GET[id] == 'detailberitalike'){
	$username = $_GET['username'];
	$id_berita = $_GET['id_berita'];
	$data = mysql_query("SELECT * FROM likes WHERE username = '$username' AND id_berita = '$id_berita'");
	$jum = mysql_num_rows($data);
	if($jum == 0){
		mysql_query("INSERT INTO likes(id_berita, username) VALUES('$id_berita','$username')"); 
	}
	$query = mysql_query("SELECT COUNT(id_likes) AS jml FROM likes");
	// Insert a new row in the table for each person returned
	while($r = mysql_fetch_array($query)){
		echo "$r[jml]";
	}
}
if($_GET[id] == 'detailberitadislike'){
	$username = $_GET['username'];
	$id_berita = $_GET['id_berita'];
	$data = mysql_query("SELECT * FROM dislike WHERE username = '$username' AND id_berita = '$id_berita'");
	$jum = mysql_num_rows($data);
	if($jum == 0){
		mysql_query("INSERT INTO dislike(id_berita, username) VALUES('$id_berita','$username')"); 
	}
	$query = mysql_query("SELECT COUNT(id_dislike) AS jml FROM dislike");
	// Insert a new row in the table for each person returned
	while($r = mysql_fetch_array($query)){
		echo "$r[jml]";
	}
}
if($_GET[id] == 'semuaberitalike_3'){
	$username = $_GET['username'];
	$id_berita = $_GET['id_berita'];
	$data = mysql_query("SELECT * FROM likes WHERE username = '$username' AND id_berita = '$id_berita'");
	$jum = mysql_num_rows($data);
	if($jum == 0){
		mysql_query("INSERT INTO likes(id_berita, username) VALUES('$id_berita','$username')"); 
	}
	$query = mysql_query("SELECT COUNT(id_likes) AS jml FROM likes");
	// Insert a new row in the table for each person returned
	while($r = mysql_fetch_array($query)){
		echo "$r[jml]";
	}
}
if($_GET[id] == 'semuaberitadislike_3'){
	$username = $_GET['username'];
	$id_berita = $_GET['id_berita'];
	$data = mysql_query("SELECT * FROM dislike WHERE username = '$username' AND id_berita = '$id_berita'");
	$jum = mysql_num_rows($data);
	if($jum == 0){
		mysql_query("INSERT INTO dislike(id_berita, username) VALUES('$id_berita','$username')"); 
	}
	$query = mysql_query("SELECT COUNT(id_dislike) AS jml FROM dislike");
	// Insert a new row in the table for each person returned
	while($r = mysql_fetch_array($query)){
		echo "$r[jml]";
	}
}

?>